import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace PerBusinessMainApi {
  /** 系统业务主表信息 */
  export interface BusinessMain {
    id: number; // 业务主键ID
    operateCategoryId?: number; // 业务分类ID
    operateCategoryCode?: string; // 业务分类编码
    operateCategoryName?: string; // 业务分类名称
    objectType?: string; // 业务对象类型（如：PERSON、ORG、POST 等）
    objectId?: number; // 业务对象ID
    objectName?: string; // 业务对象名称
    summary: string; // 摘要描述
    businessStatus: number; // 业务状态：0 草稿 1 审核中 2 审核结束
    finalAuditStatus: number; // 最终审核状态：0 待审核 1 审核通过 2 审核不通过
    currentAuditorId: number; // 当前审核人ID
    currentAuditorName: string; // 当前审核人名称
    currentAuditorUnitId: number; // 当前审核人单位ID
    currentAuditorDeptId: number; // 当前审核人部门ID
    currentAuditorAreaCode: string; // 当前审核人行政区划编码
    nextAuditorId: number; // 下级审核人ID
    nextAuditorName: string; // 下级审核人名称
    nextAuditorUnitId: number; // 下级审核人单位ID
    nextAuditorDeptId: number; // 下级审核人部门ID
    nextAuditorAreaCode: string; // 下级审核人行政区划编码
    deptId: number; // 经办人所属部门ID
    clientId: string; // 客户端编号
    unitId: number; // 经办人单位ID
    areaCode: string; // 经办人行政区划编码
    naturalYear: string; // 自然年度（yyyy）
    naturalMonth: number; // 自然年月（yyyyMM）
  }
}

/** 查询系统业务主表分页 */
export function getBusinessMainPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<PerBusinessMainApi.BusinessMain>>(
    '/system/business-main/page',
    data,
    { desensitize, encrypt },
  );
}

/** 用户个人查询审核日志信息 */
export function businessMainLog(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<PerBusinessMainApi.BusinessMain>>(
    '/system/business-main/logPage',
    data,
    { desensitize, encrypt },
  );
}

/** 查询系统业务主表详情 */
export function getBusinessMain(id: number) {
  return requestClient.get<PerBusinessMainApi.BusinessMain>(
    `/system/business-main/get?id=${id}`,
  );
}

/** 新增系统业务主表 */
export function createBusinessMain(data: PerBusinessMainApi.BusinessMain) {
  return requestClient.post('/system/business-main/create', data);
}

/** 修改系统业务主表 */
export function updateBusinessMain(data: PerBusinessMainApi.BusinessMain) {
  return requestClient.put('/system/business-main/update', data);
}

/** 删除系统业务主表 */
export function deleteBusinessMain(id: number) {
  return requestClient.delete(`/system/business-main/delete?id=${id}`);
}

/** 批量删除系统业务主表 */
export function deleteBusinessMainList(ids: number[]) {
  return requestClient.delete(
    `/system/business-main/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出系统业务主表 */
export function exportBusinessMain(params: any) {
  return requestClient.download('/system/business-main/export-excel', {
    params,
  });
}

/** 系统业务主表审核 */
export function auditBusinessMain(data: any) {
  return requestClient.post('/system/business-main/auditBusinessMain', data);
}
